In [1]:
%load_ext autoreload
%autoreload 2
import re
import pandas as pd
import aphrodite.results
import vislab
import vislab.results
import vislab.datasets

In [2]:
label_df = vislab.datasets.pascal.get_clf_df()

Normal VOC 20-class results


In [3]:
results_df, preds_panel = aphrodite.results.load_pred_results(
    'pascal_oct16', vislab.config['paths']['shared_data'] + '/results', force=False)
preds_panel


Loaded from cache: 38 records
Out[3]:
<class 'pandas.core.panel.Panel'>
Dimensions: 19 (items) x 17125 (major_axis) x 4 (minor_axis)
Items axis: clf pascal_class_aeroplane to clf pascal_class_tvmonitor
Major_axis axis: 2007_000027 to 2012_004331
Minor_axis axis: decaf_fc6  vw to split

Results for a single class.


In [23]:
selected_score = 'decaf_fc6  vw'
pred_prefix = 'clf pascal'
label = 'class_dog'

pred_df = preds_panel['{}_{}'.format(pred_prefix, label)]
pred_df['pred'] = pred_df[selected_score]
pred_df
full_binary_metrics = vislab.results.binary_metrics(
    pred_df, '{} full'.format(label), False, with_plot=True)


Results for multi-class.


In [24]:
mc_pred_df = preds_panel.minor_xs('decaf_fc6  vw').join(label_df)
pred_prefix = 'clf pascal'

In [52]:
full_mc_metrics = vislab.results.multiclass_metrics(
    mc_pred_df, pred_prefix, balanced=False,
    with_plot=True, with_print=True)


------------------------------------------------------------
Classification metrics on the full dataset
top_k_accuracies: [0.627, 0.791, 0.872, 0.919, 0.948, 0.963, 0.972, 0.981, 0.986, 0.99, 0.992, 0.994, 0.995, 0.997, 0.998, 0.998, 0.999, 1.0, 1.0]
                   precision    recall  f1-score  support
class_aeroplane     0.845722  0.842179  0.843947      716
class_bicycle       0.684800  0.709784  0.697068      603
class_bird          0.824087  0.753713  0.787330      808
class_boat          0.742215  0.812500  0.775769      528
class_bottle        0.528107  0.463636  0.493776      770
class_bus           0.930131  0.488532  0.640602      436
class_car           0.770690  0.478075  0.590099      935
class_cat           0.834171  0.755232  0.792741     1099
class_chair         0.650485  0.191246  0.295588     1051
class_cow           0.591912  0.501558  0.543002      321
class_diningtable   0.154143  0.615385  0.246533      130
class_dog           0.817500  0.569191  0.671113     1149
class_horse         0.574928  0.827801  0.678571      482
class_motorbike     0.708625  0.706977  0.707800      430
class_pottedplant   0.320080  0.626459  0.423684      257
class_sheep         0.594667  0.688272  0.638054      324
class_sofa          0.280967  0.657244  0.393651      283
class_train         0.537217  0.905455  0.674340      550
class_tvmonitor     0.397338  0.749104  0.519255      279
accuracy: 0.627028966012


In [53]:
full_mc_metrics['binary_metrics_df']


Out[53]:
accuracy ap auc mcc pr_fig results_df roc_fig
class_aeroplane 0.8603713 0.8927225 0.9859671 0.51083 None [precision, recall] None
class_bicycle 0.6527666 0.6507277 0.9429867 0.279426 None [precision, recall] None
class_bird 0.687472 0.8353669 0.969846 0.3457068 None [precision, recall] None
class_boat 0.7936508 0.784394 0.9732621 0.3799048 None [precision, recall] None
class_bottle 0.3895615 0.4901989 0.9003062 0.1835326 None [precision, recall] None
class_bus 0.8294323 0.8513738 0.9843531 0.3963753 None [precision, recall] None
class_car 0.6191373 0.6574816 0.921111 0.3464022 None [precision, recall] None
class_cat 0.6938391 0.8213718 0.96655 0.395568 None [precision, recall] None
class_chair 0.5925029 0.6581116 0.9283187 0.343856 None [precision, recall] None
class_cow 0.7318626 0.3643397 0.9508406 0.2656333 None [precision, recall] None
class_diningtable 0.716438 0.6821692 0.9559175 0.3415181 None [precision, recall] None
class_dog 0.6804771 0.7822894 0.9506014 0.4072089 None [precision, recall] None
class_horse 0.6812842 0.6853829 0.9634471 0.2867896 None [precision, recall] None
class_motorbike 0.8576809 0.7757554 0.973002 0.4565035 None [precision, recall] None
class_pottedplant 0.4234598 0.5003621 0.9111148 0.1767972 None [precision, recall] None
class_sheep 0.77437 0.5758884 0.9637824 0.2984801 None [precision, recall] None
class_sofa 0.5528652 0.4769162 0.920226 0.2547741 None [precision, recall] None
class_train 0.6713299 0.7605917 0.9719644 0.2964198 None [precision, recall] None
class_tvmonitor 0.6513317 0.6938669 0.9572594 0.2933467 None [precision, recall] None
_mean 0.6768333 0.6810164 0.9521503 0.3294249 NaN NaN NaN

Results for the 4 aggregate metaclasses


In [60]:
results_df, preds_panel = aphrodite.results.load_pred_results(
    'pascal_mc_oct16', vislab.config['paths']['shared_data'] + '/results', force=True)
preds_panel


Results in collection pascal_mc_oct16: 8
Out[60]:
<class 'pandas.core.panel.Panel'>
Dimensions: 4 (items) x 17125 (major_axis) x 4 (minor_axis)
Items axis: clf pascal_metaclass_animal to clf pascal_metaclass_vehicle
Major_axis axis: 2007_000027 to 2012_004331
Minor_axis axis: decaf_fc6  vw to split

In [61]:
mc_pred_df = preds_panel.minor_xs('decaf_fc6  vw').join(label_df)
pred_prefix = 'clf pascal'

In [63]:
full_mc_metrics = vislab.results.multiclass_metrics(
    mc_pred_df, pred_prefix, balanced=False,
    with_plot=True, with_print=True)


------------------------------------------------------------
Classification metrics on the full dataset
top_k_accuracies: [0.634, 0.925, 0.989, 1.0]
                   precision    recall  f1-score  support
metaclass_animal    0.963374  0.529758  0.683603     4419
metaclass_indoor    0.777259  0.179174  0.291217     2785
metaclass_person    0.556489  0.969392  0.707075     7449
metaclass_vehicle   0.740019  0.322411  0.449141     2472
accuracy: 0.63404379562


In [ ]:
full_mc_metrics['binary_metrics_df']